#include("../common/_header.html", crumb="博客", searchUrl="/admin/blog")

<!-- 主界面 -->
<div id="main" class="main">
	
	<!-- 工具栏 -->
	<div class="toolbar">
		<a fill href="/admin/blog/add" class="btn btn-success btn-sm">
			<i class="fa fa-plus mr-1"></i>创建
		</a>
	</div>
	
	<!-- 表格容器 -->
	<div id="table-box" class="table-box">
		
		<table class="table table-hover">
			
			<thead>
				<tr>
					<th>ID</th>
					<th>标题</th>
					<th>创建时间</th>
					<th>发布</th>
					
					<th class="operation">操作</th>
				</tr>
			</thead>
			
			<tbody>
			#for (x : page.getList())
				<tr>
					<td>#(x.id)</td>
					<td><a href="/blog/#(x.id)" target="_blank">#(x.title)</a></td>
					<td>#date(x.created)</td>
					
					<td>
						<div class="custom-control custom-switch">
	  						<input #(x.state == 1 ? 'checked':'') url='/admin/blog/publish?id=#(x.id)' type="checkbox" class="custom-control-input" id="id-#(x.id)">
	  						<label class="custom-control-label" for="id-#(x.id)"></label>
						</div>
					</td>
					
					<td class="operation">
						<a fill href="/admin/blog/edit?id=#(x.id)&pn=#(page.pageNumber)">修改</a> |
						
						### 这里用 url 代替 href 是为了防止意外删除数据
						<a confirm="确定删除 #escape(x.title) ？" ok-remove="tr" url="/admin/blog/delete?id=#(x.id)">删除</a>
					</td>
				</tr>
			#end
			</tbody>
			
		</table>
	</div>
	
	<!-- 分页 -->
	### 将 searchKey 放入 append，促使分页链接中追加该参数用于搜索
	#if (StrKit.notBlank(searchKey)) #set(append = '&searchKey=' + searchKey) #end
	#@adminPaginate(page.pageNumber, page.totalPage, "/admin/blog?pn=")
	
</div>




